﻿using System;

namespace Demo
{
    class Program
    {
        static void Main(string[] args)
        {
            test6();
        }
        public static void test()
        {
            //            用户输入正方形边长，用* 打印出实心正方形。

            //如：用户输入5，则输出如下图形。
            //*****
            //*****
            //*****
            //*****
            //*****

            Console.WriteLine("请输入正方形的边长");
            int c = int.Parse(Console.ReadLine());
            for (int i = 0; i < c; i++)
            {
                for (int j = 0; j < c; j++)
                {

                    Console.Write("*" + " ");
                }
                Console.WriteLine();
            }
            Console.ReadKey();
        }
        public static void test1()
        {

            //            1 * 1 = 1
            //2 * 1 = 2   2 * 2 = 4
            //3 * 1 = 3   3 * 2 = 6   3 * 3 = 9
            //4 * 1 = 4   4 * 2 = 8   4 * 3 = 12  4 * 4 = 16
            //5 * 1 = 5   5 * 2 = 10  5 * 3 = 15  5 * 4 = 20  5 * 5 = 25
            //6 * 1 = 6   6 * 2 = 12  6 * 3 = 18  6 * 4 = 24  6 * 5 = 30  6 * 6 = 36
            //7 * 1 = 7   7 * 2 = 14  7 * 3 = 21  7 * 4 = 28  7 * 5 = 35  7 * 6 = 42  7 * 7 = 49
            //8 * 1 = 8   8 * 2 = 16  8 * 3 = 24  8 * 4 = 32  8 * 5 = 40  8 * 6 = 48  8 * 7 = 56  8 * 8 = 64
            //9 * 1 = 9   9 * 2 = 18  9 * 3 = 27  9 * 4 = 36  9 * 5 = 45  9 * 6 = 54  9 * 7 = 63  9 * 8 = 72  9 * 9 = 81

            Console.WriteLine("请输入九九乘法表");
            int[,] arr = new int[9, 9];
            for (int i = 0; i < 9; i++)
            {
                for (int j = 0; j <= i; j++)
                {
                    Console.Write((i + 1) + "*" + (j + 1) + "=" + (i + 1) * (j + 1) + " ");
                }
                Console.WriteLine();
            }

            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {

                }

            }

        }
        public static void test2()
        {
            //            用户输入正方形边长，用* 打印出空心正方形。

            //如：用户输入5，则输出如下图形。
            //*****
            //*   *
            //*   *
            //*   *
            //*****  
            Console.WriteLine("用户输入正方形边长");
            int c = int.Parse(Console.ReadLine());
            string[,] arr = new string[c, c];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    arr[i, j] = "*";
                }
            }
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int j = 0; j < arr.GetLength(1); j++)
                {
                    if (i == 0 || j == 0 || i == arr.GetLength(0) - 1 || j == arr.GetLength(1) - 1)
                    {
                        Console.Write(arr[i, j]);
                    }
                    else
                    {
                        Console.Write(" ");
                    }
                }
                Console.WriteLine();
            }
        }
        public static void test3() {

            //如果一个数组保存元素是有序的（从大到小），
            //    向这个数组中插入一个数，使得插入后的数组元素仍然保持有序。
            int[] arr = new int[6];
            arr[0] = 100;
            arr[1] = 90;
            arr[2] = 88;
            arr[3] = 75;
            arr[4] = 66;
            Console.WriteLine("原数组：");
            for (int i = 0; i < arr.Length; i++)
            {
                if (i == 5)
                {

                }
                else
                {
                    Console.Write(arr[i] + " ");
                }
            }
            Console.WriteLine();
            Console.WriteLine("请输入一个数：");
            int a = int.Parse(Console.ReadLine());
            arr[5] = a;
            Array.Sort(arr);
            Array.Reverse(arr);
            Console.WriteLine("排序后：");
            for (int i = 0; i < arr.Length; i++)
            {
                Console.Write(arr[i] + " ");
            }
        }

        public static void test5()
        {

            Console.WriteLine("请输入杨辉三角行数：");
            int b = Convert.ToInt32(Console.ReadLine());
            int[,] arr = new int[b, b];
            for (int i = 0; i < arr.GetLength(0); i++)
            {
                for (int k = 0; k <= i; k++)
                {
                    if (k == 0 || k == i)
                    {
                        arr[i, k] = 1;
                    }
                    else
                    {
                        arr[i, k] = arr[i - 1, k - 1] + arr[i - 1, k];
                    }
                }
            }
            for (int m = 0; m < arr.GetLength(0); m++)
            {
                for (int n = 0; n <= m; n++)
                {
                    Console.Write(arr[m, n] + "\t");
                }
                Console.WriteLine();
            }
        }
        public static void test6()
        {
            int[] arr = { 5, 1, 4, 8, 7 };
            for (int i = 0; i < arr.Length; i++)
            {
                if (i % 2 == 0)
                {
                    Console.WriteLine(arr[i]);
                }
            }
        }
    }

}

